<template>
	<div class="hm-news-card">
		<div class="container">
			<div class="box">
				<img class="img" @click="onClick" :src="BASE_IMG + options.img" />
				<span class="title">{{ options.title }}</span>
				<div class="submain">
					<span class="author">作者：{{ options.author }}</span>
					<span class="date">发布时间：{{ options.sendTime }}</span>
				</div>
				<span class="summary">
					文章标签：
					<uni-tag class="summary-text" v-for="(item,index) in labels" :text="item" :key="index" type="primary" />
				</span>

				<div class="row_2" />
				<div class="ft">
					<span class="text">{{ options.evaluate }} 评论</span>
					<span class="text">{{ options.see }} 浏览</span>
					<span class="text">{{ options.likeNum }} 喜欢</span>
				</div>
			</div>
		</div>
	</div>
</template>

<script setup>
	import { ref } from 'vue';
import {
		BASE_IMG
	} from '@/utils/imgComBaseUrl.js';
	const {
		options
	} = defineProps({
		options: {
			type: Object,
			default: {
				articleLabel: "python",
				author: "admin",
				evaluate: 0,
				id: 419,
				img: "/profile/upload/2025/02/06/稿定设计-4_20250206205915A002.jpg",
				likeNum: 0,
				see: 1,
				sendTime: "2025-02-06 20:59:18",
				title: "554",
			}
		}
	})

const labels = ref([])
	function handleLabel() {
		const res = options.articleLabel.split(',');
		labels.value = res
	}

	async function onClick() {
		const userData = uni.getStorageSync("userInfo");
		
		if(userData === ''){
			await uni.showToast({
				title:"请先登录",
				icon:"none",
			})
			await uni.redirectTo({
				url:"/pages/login/login"
			})
			return
		}
		uni.navigateTo({
			url: '/pages/article-details/article-details?id=' + options.id
		});
	}
	handleLabel()
</script>

<style lang="scss">
	@import './index.response.css';
</style>